package com.darren.euc.dao.impl;


import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.darren.euc.dao.ClueDao;
import com.darren.euc.entity.Clue;


@Repository
public class ClueDaoImpl extends BaseDaoImpl<Clue, Integer> implements ClueDao {
	
	@Override
	public List<Clue> getAll() {
		Session session = sessionFactory.getCurrentSession();	
		@SuppressWarnings("unchecked")
		List<Clue> clues = session.createQuery("from Clue where enable = true").list();
		return clues;
	}
	
	
	@Override
	public Clue findByClientId(Integer clientId){
		Session session = sessionFactory.getCurrentSession();	
		Clue clue = (Clue) session.createQuery(" from Clue where client.id = ? and  enable = true").setParameter(0, clientId).uniqueResult();
		return clue;
	}


}